<!DOCTYPE html>
<html>
<head>
    <title>登录</title>
    <script src="/static/js/jquery-3.2.1.min.js"></script>
</head>
<script src="/static/js/jquery-3.2.1.min.js"></script>
<!-- Site CSS -->
<link href="/static/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="/static/bootstrap-3.3.7/js/bootstrap.min.js"
        integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
        crossorigin="anonymous"></script>
<body>
{__NOLAYOUT__}
<form method="post" class="panel-body wrapper-lg form-horizontal">
    <div class="row">
        <div class="col-md-3 col-md-offset-4">
            <div class="form-group">
                <label for="username" class="col-sm-2 control-label">用户名:</label>
                <div class="col-sm-10">
                    <input type="username" class="form-control" id="username" placeholder="账户">
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-3 col-md-offset-4">
            <div class="form-group">
                <label for="password" class="col-sm-2 control-label">密码:</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="password" placeholder="密码">
                </div>
            </div>
        </div>
    </div>

    <!--<div class="row">-->
        <!--<div class="col-md-3 col-md-offset-4">-->
            <!--<div class="form-group">-->
                <!--<label for="captcha" class="col-sm-2 control-label">验证码:</label>-->
                <!--<div class="col-sm-5 col-sm-offset-1">-->
                    <!--<img src="{:captcha_src()}" alt="captcha" onclick="this.src=this.src+'?'+Math.random()"/></br>-->
                <!--</div>-->
                <!--<div class="col-sm-10 col-sm-offset-2">-->
                    <!--<input type="text" class="form-control" id="captcha" placeholder="验证码">-->
                <!--</div>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
    <div class="row">
        <div class="form-group">
            <div class="col-sm-offset-6 col-sm-10">
                <button type="button" class="btn btn-primary" id="login-btn">登录</button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    $("#login-btn").click(function () {
        var username = $("#username").val();
        var password = $("#password").val();
        // var code = $("#captcha").val();

        if (username == '' || password == '') {
            alert('username or password error');
            return false;
        }

        $.ajax({
            url: "{:url('backend/Account/doLogin')}",
            method: "POST",
            data: {"username": username, "password": password},
            dataType: "json",
            success: function (res) {
                if (res.status === 1) {
                    window.location.href = "{:url('backend/Index/index')}";
                }
                else {
                    alert(res.msg);
                }
            }
        });
    });
</script>
</body>
</html>